<template>
    <div id="app">
        <el-container>
            <el-header class="app" v-show="show">
                <div></div>
                <div>
                    <el-menu
                        class="el-menu-demo"
                        mode="horizontal"
                        background-color="#545c64"
                        text-color="#fff"
                        active-text-color="#ffd04b"
                        router
                    >
                        <el-menu-item > <span>{{user}}</span> 登录|注册</el-menu-item>
                        <el-menu-item index="/ding">我的订单</el-menu-item>
                        <el-menu-item index="/shou">我的收藏</el-menu-item>
                        <el-menu-item index="/shoplist">购物车</el-menu-item>
                    </el-menu>
                </div>
            </el-header>
            <el-main v-show="show">
                <el-menu class="el-menu-demo" mode="horizontal" router>
                    <el-menu-item index="/">首页</el-menu-item>
                    <el-menu-item index="/quan">全部商品</el-menu-item>
                    <el-menu-item index="/guan">关于我们</el-menu-item>
                </el-menu>
            </el-main>
            <el-footer><router-view></router-view></el-footer>
        </el-container>
    </div>
</template>
<script>
export default {
    data() {
        return {
            show:true,
            user:""
            
        }
    },
    mounted() {
        this.user=localStorage.getItem("token")
    },
       watch: {
        $route: {
            handler(newval, oldval) {
                console.log(newval, oldval);
                if (newval.path == "/login") {
                    this.show = false;
                } else {
                    this.show = true;
                }
            },
        },
        
    },
}
</script>
<style lang="scss" scoped>
#app {
    font-family: Avenir, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-align: center;
    color: #2c3e50;
}

#nav {
    padding: 30px;

    a {
        font-weight: bold;
        color: #2c3e50;

        &.router-link-exact-active {
            color: #42b983;
        }
    }
}
.app {
    display: flex;
    justify-content: space-between;
    background: #545c64;
}
ul{
    list-style: none;
}
</style>
